Optimal. Leaf size=248 \[ \left (a^2 (A c-c C-B d)-b^2 (A c-c C-B d)-2 a b (B c+(A-C) d)\right ) x-\frac {\left (2 a b (A c-c C-B d)+a^2 (B c+(A-C) d)-b^2 (B c+(A-C) d)\right ) \log (\cos (e+f x))}{f}+\frac {b (A b c+a B c-b c C+a A d-b B d-a C d) \tan (e+f x)}{f}+\frac {(B c+(A-C) d) (a+b \tan (e+f x))^2}{2 f}-\frac {(a C d-4 b (c C+B d)) (a+b \tan (e+f x))^3}{12 b^2 f}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.31, antiderivative size = 248, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 43, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.116, Rules used = {3718, 3711,
3609, 3606, 3556} \begin {gather*} -\frac {\log (\cos (e+f x)) \left (a^2 (d (A-C)+B c)+2 a b (A c-B d-c C)-b^2 (d (A-C)+B c)\right )}{f}+x \left (a^2 (A c-B d-c C)-2 a b (d (A-C)+B c)-b^2 (A c-B d-c C)\right )+\frac {(d (A-C)+B c) (a+b \tan (e+f x))^2}{2 f}+\frac {b \tan (e+f x) (a A d+a B c-a C d+A b c-b B d-b c C)}{f}-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{12 b^2 f}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 3556
Rule 3606
Rule 3609
Rule 3711
Rule 3718
Rubi steps
\begin {align*} \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx &=\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}-\frac {\int (a+b \tan (e+f x))^2 \left (-4 A b c+a C d-4 b (B c+(A-C) d) \tan (e+f x)+(a C d-4 b (c C+B d)) \tan ^2(e+f x)\right ) \, dx}{4 b}\\ &=-\frac {(a C d-4 b (c C+B d)) (a+b \tan (e+f x))^3}{12 b^2 f}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}-\frac {\int (a+b \tan (e+f x))^2 (-4 b (A c-c C-B d)-4 b (B c+(A-C) d) \tan (e+f x)) \, dx}{4 b}\\ &=\frac {(B c+(A-C) d) (a+b \tan (e+f x))^2}{2 f}-\frac {(a C d-4 b (c C+B d)) (a+b \tan (e+f x))^3}{12 b^2 f}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}-\frac {\int (a+b \tan (e+f x)) (4 b (b B c+b (A-C) d-a (A c-c C-B d))-4 b (A b c+a B c-b c C+a A d-b B d-a C d) \tan (e+f x)) \, dx}{4 b}\\ &=\left (a^2 (A c-c C-B d)-b^2 (A c-c C-B d)-2 a b (B c+(A-C) d)\right ) x+\frac {b (A b c+a B c-b c C+a A d-b B d-a C d) \tan (e+f x)}{f}+\frac {(B c+(A-C) d) (a+b \tan (e+f x))^2}{2 f}-\frac {(a C d-4 b (c C+B d)) (a+b \tan (e+f x))^3}{12 b^2 f}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}-\left (-2 a b (A c-c C-B d)-a^2 (B c+(A-C) d)+b^2 (B c+(A-C) d)\right ) \int \tan (e+f x) \, dx\\ &=\left (a^2 (A c-c C-B d)-b^2 (A c-c C-B d)-2 a b (B c+(A-C) d)\right ) x-\frac {\left (2 a b (A c-c C-B d)+a^2 (B c+(A-C) d)-b^2 (B c+(A-C) d)\right ) \log (\cos (e+f x))}{f}+\frac {b (A b c+a B c-b c C+a A d-b B d-a C d) \tan (e+f x)}{f}+\frac {(B c+(A-C) d) (a+b \tan (e+f x))^2}{2 f}-\frac {(a C d-4 b (c C+B d)) (a+b \tan (e+f x))^3}{12 b^2 f}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 2.27, size = 243, normalized size = 0.98 \begin {gather*} \frac {\frac {(-a C d+4 b (c C+B d)) (a+b \tan (e+f x))^3}{b}+3 C d \tan (e+f x) (a+b \tan (e+f x))^3-6 (A b c-a B c-b c C-a A d-b B d+a C d) \left (i \left ((a+i b)^2 \log (i-\tan (e+f x))-(a-i b)^2 \log (i+\tan (e+f x))\right )-2 b^2 \tan (e+f x)\right )+6 (B c+(A-C) d) \left ((i a-b)^3 \log (i-\tan (e+f x))-(i a+b)^3 \log (i+\tan (e+f x))+6 a b^2 \tan (e+f x)+b^3 \tan ^2(e+f x)\right )}{12 b f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.12, size = 386, normalized size = 1.56
method | result | size |
norman | \(\left (A \,a^{2} c -2 A a b d -A \,b^{2} c -B \,a^{2} d -2 B a b c +B \,b^{2} d -C \,a^{2} c +2 C a b d +C \,b^{2} c \right ) x +\frac {\left (2 A a b d +A \,b^{2} c +B \,a^{2} d +2 B a b c -B \,b^{2} d +C \,a^{2} c -2 C a b d -C \,b^{2} c \right ) \tan \left (f x +e \right )}{f}+\frac {\left (A \,b^{2} d +2 B a b d +B \,b^{2} c +C \,a^{2} d +2 C a b c -C \,b^{2} d \right ) \left (\tan ^{2}\left (f x +e \right )\right )}{2 f}+\frac {b \left (B b d +2 a C d +C b c \right ) \left (\tan ^{3}\left (f x +e \right )\right )}{3 f}+\frac {C \,b^{2} d \left (\tan ^{4}\left (f x +e \right )\right )}{4 f}+\frac {\left (A \,a^{2} d +2 A a b c -A \,b^{2} d +B \,a^{2} c -2 B a b d -B \,b^{2} c -C \,a^{2} d -2 C a b c +C \,b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 f}\) | \(294\) |
derivativedivides | \(\frac {\frac {C \,b^{2} d \left (\tan ^{4}\left (f x +e \right )\right )}{4}+\frac {B \,b^{2} d \left (\tan ^{3}\left (f x +e \right )\right )}{3}+\frac {2 C a b d \left (\tan ^{3}\left (f x +e \right )\right )}{3}+\frac {C \,b^{2} c \left (\tan ^{3}\left (f x +e \right )\right )}{3}+\frac {A \,b^{2} d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+B a b d \left (\tan ^{2}\left (f x +e \right )\right )+\frac {B \,b^{2} c \left (\tan ^{2}\left (f x +e \right )\right )}{2}+\frac {C \,a^{2} d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+C a b c \left (\tan ^{2}\left (f x +e \right )\right )-\frac {C \,b^{2} d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+2 A a b d \tan \left (f x +e \right )+A \,b^{2} c \tan \left (f x +e \right )+B \,a^{2} d \tan \left (f x +e \right )+2 B a b c \tan \left (f x +e \right )-B \,b^{2} d \tan \left (f x +e \right )+C \,a^{2} c \tan \left (f x +e \right )-2 C a b d \tan \left (f x +e \right )-C \,b^{2} c \tan \left (f x +e \right )+\frac {\left (A \,a^{2} d +2 A a b c -A \,b^{2} d +B \,a^{2} c -2 B a b d -B \,b^{2} c -C \,a^{2} d -2 C a b c +C \,b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (A \,a^{2} c -2 A a b d -A \,b^{2} c -B \,a^{2} d -2 B a b c +B \,b^{2} d -C \,a^{2} c +2 C a b d +C \,b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) | \(386\) |
default | \(\frac {\frac {C \,b^{2} d \left (\tan ^{4}\left (f x +e \right )\right )}{4}+\frac {B \,b^{2} d \left (\tan ^{3}\left (f x +e \right )\right )}{3}+\frac {2 C a b d \left (\tan ^{3}\left (f x +e \right )\right )}{3}+\frac {C \,b^{2} c \left (\tan ^{3}\left (f x +e \right )\right )}{3}+\frac {A \,b^{2} d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+B a b d \left (\tan ^{2}\left (f x +e \right )\right )+\frac {B \,b^{2} c \left (\tan ^{2}\left (f x +e \right )\right )}{2}+\frac {C \,a^{2} d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+C a b c \left (\tan ^{2}\left (f x +e \right )\right )-\frac {C \,b^{2} d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+2 A a b d \tan \left (f x +e \right )+A \,b^{2} c \tan \left (f x +e \right )+B \,a^{2} d \tan \left (f x +e \right )+2 B a b c \tan \left (f x +e \right )-B \,b^{2} d \tan \left (f x +e \right )+C \,a^{2} c \tan \left (f x +e \right )-2 C a b d \tan \left (f x +e \right )-C \,b^{2} c \tan \left (f x +e \right )+\frac {\left (A \,a^{2} d +2 A a b c -A \,b^{2} d +B \,a^{2} c -2 B a b d -B \,b^{2} c -C \,a^{2} d -2 C a b c +C \,b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (A \,a^{2} c -2 A a b d -A \,b^{2} c -B \,a^{2} d -2 B a b c +B \,b^{2} d -C \,a^{2} c +2 C a b d +C \,b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) | \(386\) |
risch | \(\text {Expression too large to display}\) | \(1191\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.50, size = 280, normalized size = 1.13 \begin {gather*} \frac {3 \, C b^{2} d \tan \left (f x + e\right )^{4} + 4 \, {\left (C b^{2} c + {\left (2 \, C a b + B b^{2}\right )} d\right )} \tan \left (f x + e\right )^{3} + 6 \, {\left ({\left (2 \, C a b + B b^{2}\right )} c + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d\right )} \tan \left (f x + e\right )^{2} + 12 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c - {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} {\left (f x + e\right )} + 6 \, {\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c + {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 12 \, {\left ({\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} \tan \left (f x + e\right )}{12 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 3.35, size = 278, normalized size = 1.12 \begin {gather*} \frac {3 \, C b^{2} d \tan \left (f x + e\right )^{4} + 4 \, {\left (C b^{2} c + {\left (2 \, C a b + B b^{2}\right )} d\right )} \tan \left (f x + e\right )^{3} + 12 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c - {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} f x + 6 \, {\left ({\left (2 \, C a b + B b^{2}\right )} c + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d\right )} \tan \left (f x + e\right )^{2} - 6 \, {\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c + {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 12 \, {\left ({\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} \tan \left (f x + e\right )}{12 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 617 vs.
\(2 (218) = 436\).
time = 0.23, size = 617, normalized size = 2.49 \begin {gather*} \begin {cases} A a^{2} c x + \frac {A a^{2} d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {A a b c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - 2 A a b d x + \frac {2 A a b d \tan {\left (e + f x \right )}}{f} - A b^{2} c x + \frac {A b^{2} c \tan {\left (e + f x \right )}}{f} - \frac {A b^{2} d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {A b^{2} d \tan ^{2}{\left (e + f x \right )}}{2 f} + \frac {B a^{2} c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - B a^{2} d x + \frac {B a^{2} d \tan {\left (e + f x \right )}}{f} - 2 B a b c x + \frac {2 B a b c \tan {\left (e + f x \right )}}{f} - \frac {B a b d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} + \frac {B a b d \tan ^{2}{\left (e + f x \right )}}{f} - \frac {B b^{2} c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {B b^{2} c \tan ^{2}{\left (e + f x \right )}}{2 f} + B b^{2} d x + \frac {B b^{2} d \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {B b^{2} d \tan {\left (e + f x \right )}}{f} - C a^{2} c x + \frac {C a^{2} c \tan {\left (e + f x \right )}}{f} - \frac {C a^{2} d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {C a^{2} d \tan ^{2}{\left (e + f x \right )}}{2 f} - \frac {C a b c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} + \frac {C a b c \tan ^{2}{\left (e + f x \right )}}{f} + 2 C a b d x + \frac {2 C a b d \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {2 C a b d \tan {\left (e + f x \right )}}{f} + C b^{2} c x + \frac {C b^{2} c \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {C b^{2} c \tan {\left (e + f x \right )}}{f} + \frac {C b^{2} d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {C b^{2} d \tan ^{4}{\left (e + f x \right )}}{4 f} - \frac {C b^{2} d \tan ^{2}{\left (e + f x \right )}}{2 f} & \text {for}\: f \neq 0 \\x \left (a + b \tan {\left (e \right )}\right )^{2} \left (c + d \tan {\left (e \right )}\right ) \left (A + B \tan {\left (e \right )} + C \tan ^{2}{\left (e \right )}\right ) & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 6502 vs.
\(2 (248) = 496\).
time = 3.76, size = 6502, normalized size = 26.22 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 8.98, size = 300, normalized size = 1.21 \begin {gather*} \frac {{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (\frac {A\,b^2\,d}{2}+\frac {B\,b^2\,c}{2}+\frac {C\,a^2\,d}{2}-\frac {C\,b^2\,d}{2}+B\,a\,b\,d+C\,a\,b\,c\right )}{f}-x\,\left (A\,b^2\,c-A\,a^2\,c+B\,a^2\,d+C\,a^2\,c-B\,b^2\,d-C\,b^2\,c+2\,A\,a\,b\,d+2\,B\,a\,b\,c-2\,C\,a\,b\,d\right )-\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {A\,b^2\,d}{2}-\frac {B\,a^2\,c}{2}-\frac {A\,a^2\,d}{2}+\frac {B\,b^2\,c}{2}+\frac {C\,a^2\,d}{2}-\frac {C\,b^2\,d}{2}-A\,a\,b\,c+B\,a\,b\,d+C\,a\,b\,c\right )}{f}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (A\,b^2\,c+B\,a^2\,d+C\,a^2\,c-B\,b^2\,d-C\,b^2\,c+2\,A\,a\,b\,d+2\,B\,a\,b\,c-2\,C\,a\,b\,d\right )}{f}+\frac {{\mathrm {tan}\left (e+f\,x\right )}^3\,\left (\frac {B\,b^2\,d}{3}+\frac {C\,b^2\,c}{3}+\frac {2\,C\,a\,b\,d}{3}\right )}{f}+\frac {C\,b^2\,d\,{\mathrm {tan}\left (e+f\,x\right )}^4}{4\,f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________